//pages/previewVisit/previewVisit.js
var app = getApp();
let animationShowHeight = 600; // 假设设计稿宽度是屏幕宽度的2倍

Page({
  data:{
    app:app,
    show:true,
    animationData:"",
    showModalStatus:false,
    imageHeight:0,
    imageWidth:0
  },
  
  onSelect(event) {
    const index = event.currentTarget.dataset.index;
    switch (index) {
      case '0':
        // 处理“我要预约”按钮的点击事件
        console.log('我要预约按钮被点击');
        wx.navigateTo({
          url: '/packageBook/pages/previewVisit/previewVisit1/previewVisit1'
        });
        break;
      case '1':
        // 处理“我的预约”按钮的点击事件
        console.log('我的预约按钮被点击');
        wx.navigateTo({
          url: '/packageBook/pages/appointHistory/appointHistory'
        });
        break;
      case '2':
        // 处理“参加须知”按钮的点击事件
        console.log('参加须知按钮被点击');
        wx.navigateTo({
          url: '/packageBook/pages/previewVisit/previewVisit3/previewVisit3'
        });
        break;
      default:
        break;
    }
  },
  imageLoad: function (e) {  
    this.setData({imageHeight:e.detail.height,imageWidth:e.detail.width});  
  },
  showModal: function () {
    this.setData({
      marginTop:"100%"
    })
    // 显示遮罩层
    var animation = wx.createAnimation({
        duration: 200,
        timingFunction: "linear",
        delay: 0
    })
    this.animation = animation
    animation.translateY(animationShowHeight).step()
    this.setData({
        animationData: animation.export(),
        showModalStatus: true
    })
    setTimeout(function () {
        animation.translateY(-700).step() // 假设设计稿高度是屏幕高度的2倍
        this.setData({
            animationData: animation.export()
        })
    }.bind(this),0)//增加秒数会那个啥
  },
  hideModal: function () {
    this.setData({
      marginTop:"180%"
    })
    // 隐藏遮罩层
    var animation = wx.createAnimation({
        duration: 200,
        timingFunction: "linear",
        delay: 0
    })
    this.animation = animation;
    animation.translateY(animationShowHeight).step()
    this.setData({
        animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(20).step() // 假设设计稿高度是屏幕高度的2倍
      this.setData({
          animationData: animation.export(),
          showModalStatus: false
      })
    }.bind(this))
  },
  onShow:function(){
    let that = this;
    wx.getSystemInfo({
      success: function(res) {
        animationShowHeight = res.windowHeight * 2; // 假设设计稿高度是屏幕高度的2倍
      }
    })
  },
 
})